package com.ccc.boot.util;

import com.ccc.boot.constant.AddrConstant;

import java.util.Objects;

/**
 * 行政分区工具类
 *
 * @author superC
 * @version 2.0.0
 * @date 2020/12/21
 */

public class AddrUtils {

    public static String getAdCdLike(String adCd, String level) {
        String adCdStr = "";

        if (Objects.equals(AddrConstant.LEVEL_B, level)) {
            adCdStr = adCd.substring(0, 2);
        } else if (Objects.equals(AddrConstant.LEVEL_C, level)) {
            adCdStr = adCd.substring(0, 4);
        } else if (Objects.equals(AddrConstant.LEVEL_D, level)) {
            adCdStr = adCd;
        }

        return adCdStr;
    }
}
